package MuleBackend;

import java.awt.Color;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;
import javax.swing.text.html.StyleSheet;

public class StorePanel extends JPanel {
	Town town;
	JLabel townMule;
	JLabel townFood;
	JLabel townEnergy;
	JLabel townSmithore;
	JLabel townMuleValue;
	JLabel townFoodValue;
	JLabel townEnergyValue;
	JLabel townSmithoreValue;
	
	public StorePanel() {
		town = GameDriver.game.getTown();
		
		setLayout(null);
		setSize(180,100);
		
		//add town
		TitledBorder title = new TitledBorder("Town Store");
		title.setBorder(new LineBorder(Color.BLACK, 2));
		setBorder(title);
		
		//add resources		
		townMule = new JLabel("Mule :");
		add(townMule);
		townMule.setBounds(10,20,90,18);
		
		townFood = new JLabel("Food :");
		add(townFood);
		townFood.setBounds(10,38,90,18);
		
		townEnergy = new JLabel("Energy :");
		add(townEnergy);
		townEnergy.setBounds(10,56,90,18);
		
		townSmithore = new JLabel("Smithore :");
		add(townSmithore);
		townSmithore.setBounds(10,74,90,18);
		
		
		
		//add values		
		townMuleValue = new JLabel("" + town.getMuleStock()+"");
		add(townMuleValue);
		townMuleValue.setBounds(100,20,80,18);
		
		townFoodValue = new JLabel("" + town.getFoodStock()+"");
		add(townFoodValue);
		townFoodValue.setBounds(100,38,80,18);
		
		townEnergyValue = new JLabel("" + town.getEnergyStock()+"");
		add(townEnergyValue);
		townEnergyValue.setBounds(100,56,80,18);
		
		townSmithoreValue = new JLabel("" + town.getSmithoreStock());
		add(townSmithoreValue);
		townSmithoreValue.setBounds(100,74,80,18);
	}
	
	/**
	 * Update's the information panel whenever there
	 * is a change in a town store's inventory
	 */
	public void updatePanel() {
		townMuleValue.setText("" + town.getMuleStock());
		townFoodValue.setText("" + town.getFoodStock());
		townEnergyValue.setText("" + town.getEnergyStock());
		townSmithoreValue.setText("" + town.getSmithoreStock());
		repaint();
	}
}
